/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fjut.sel1602.csp.Dao.impl;

import edu.fjut.sel1602.csp.Dao.AccountDao;
import edu.fjut.sel1602.csp.entity.Account;
import edu.fjut.sel1602.csp.util.BaseDao;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author lenovo
 */
public class AccountDaoImpl implements AccountDao{

    @Override
    public int add(Account account) {
        int r=0;
        try {
            Connection con=BaseDao.getConnection();
            PreparedStatement pst=con.prepareStatement("insert into account(DEAL_TYPE,PET_ID,SELLER_ID,BUYER_ID,PRICE,DEAL_TIME) values(?,?,?,?,?,?)");
            pst.setInt(1, account.getDealtype());
            pst.setInt(2, account.getPetid());
            pst.setInt(3, account.getSellerid());
            pst.setInt(4, account.getBuyerid());
            pst.setInt(5, account.getPrice());
            pst.setString(6,account.getDealtime());
            r=pst.executeUpdate();
            BaseDao.closeConnection(con); 
        } catch (SQLException ex) {
            Logger.getLogger(PetDaoOracleImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return r;
        
    }

   
    }
    
   
    

